package thinkingJava.chapter12;

public class Rethrowing {
	public static void f() throws Exception {
		System.out.println("originating exception from f()");
		throw new Exception("Exception from f()");
	}
	public static void g() throws Exception {
		try {
			f();
		} catch (Exception e) {
			System.out.println("throw Exception from g() : ");
			e.printStackTrace(System.out);
			throw e;
		}
	}
	public static void h() throws Exception {
		try {
			g();
		} catch (Exception e) {
			System.out.println("throw from h() : ");
			e.printStackTrace(System.out);
			throw (Exception)e.fillInStackTrace();
		}
	}
	public static void main(String[] args) {
		try {
			g();
		} catch (Exception e) {
			System.out.println("main : e.printStackTrace() ");
			e.printStackTrace(System.out);
		}
		try {
			h();
		} catch (Exception e) {
			System.out.println("main : e.printStackTrace() ");
			e.printStackTrace(System.out);
		}
	}
}
